//SKU模块接口
import request from "@/utils/request"
import type { SkuInfoData, SkuMessageData } from './type'

//SKU模块接口地址
enum API {
    //获取已有的SKU数据
    SKU_URL = 'admin/product/list/',
    //上架
    SALE_URL = 'admin/product/onSale/',
    //下架
    CANCLE_URL = 'admin/product/cancelSale/',
    //获取商品详情
    SKUINFO_URL = 'admin/product/getSkuInfo/',
    //删除商品
    DELETESKU_URL = 'admin/product/deleteSku/'
}

//获取已有的SKU数据的接口方法
export const reqSkuList = (page: number, limit: number) => 
    request.get<any, SkuInfoData>(API.SKU_URL + `${page}/${limit}`)
//上架的接口方法
export const reqSaleSku = (skuId: number) =>
    request.get<any, any>(API.SALE_URL + skuId)
//下架的接口方法
export const reqCancleSaleSku = (skuId: number) =>
    request.get<any, any>(API.CANCLE_URL + skuId)
//获取商品详情的接口方法
export const reqSkuInfo = (skuId: number) =>
    request.get<any, SkuMessageData>(API.SKUINFO_URL + skuId)
//删除商品的接口方法
export const reqDeleteSku = (skuId: number) =>
    request.delete<any, any>(API.DELETESKU_URL + skuId)
